package com.vf.admin.client.service.impl;

import com.vf.admin.client.dao.*;
import com.vf.admin.client.service.AppSetupService;
import com.vf.admin.miaodong.entity.AppSetup;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * 系统配置
 */
@Service
public class AppSetupServiceImpl implements AppSetupService {

    @Autowired
    AppSetupDao appSetupDao;
    @Autowired
    AppUserDao appUserDao;
    @Autowired
    AppUserSettingDao appUserSettingDao;
    @Autowired
    AppAuthUserDao appAuthUserDao;
    @Autowired
    AppCashWithdrawalDao appCashWithdrawalDao;
    @Autowired
    AppCommentDao appCommentDao;
    @Autowired
    AppCommentDianzanDao appCommentDianzanDao;
    @Autowired
    AppCommentReplyDao appCommentReplyDao;
    @Autowired
    AppDynamicDao appDynamicDao;
    @Autowired
    AppDynamicDianzanDao appDynamicDianzanDao;
    @Autowired
    AppFamilyMemberDao appFamilyMemberDao;
    @Autowired
    AppFeedbackDao appFeedbackDao;
    @Autowired
    AppFollowDao appFollowDao;
    @Autowired
    AppGuardDao appGuardDao;
    @Autowired
    AppIntimacyGuardDao appIntimacyGuardDao;
    @Autowired
    AppInvitationRecordDao appInvitationRecordDao;
    @Autowired
    AppSuggestDao appSuggestDao;
    @Autowired
    AppVisitorDao appVisitorDao;
    @Autowired
    MessageChatFromDao messageChatFromDao;
    @Autowired
    LovelyGodLogDao lovelyGodLogDao;

    @Override
    public AppSetup get() {
        return appSetupDao.get();
    }

    @Override
    public void save(AppSetup haoYou) {
        appSetupDao.save(haoYou);
    }

    @Override
    public void del(Integer id) {
        appSetupDao.del(id);
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public void writeOff(Integer userId) {
        appUserDao.delUser(userId);
        appUserSettingDao.delByUserId(userId);
        appAuthUserDao.delByUserId(userId);
        appCommentDao.delByUserId(userId);
        appCommentDianzanDao.delByUserId(userId);
        appCommentReplyDao.delByUserId(userId);
        appDynamicDao.delByUserId(userId);
        appDynamicDianzanDao.delByUserId(userId);
        appFamilyMemberDao.delByUserId(userId);
        appFeedbackDao.delByUserId(userId);
        appFollowDao.delByUserId(userId);
        appGuardDao.delByUserId(userId);
        appIntimacyGuardDao.delByUserId(userId);
        appInvitationRecordDao.delByUserId(userId);
        appSuggestDao.deleteByUserId(userId);
        appVisitorDao.delByUserId(userId);
        messageChatFromDao.delByUserId(userId);
        lovelyGodLogDao.delByUserId(userId);
    }

    @Override
    public String getSmsType() {
        AppSetup setup = appSetupDao.get();
        return setup.getSmsType();
    }
}
